﻿/*----------------------------------------------------------------
// Copyright (C) 2011 
// 版权所有。 
//
// 文件名：DrawArc.cs
// 文件功能描述：绘制圆弧
//
// 
// 创建标识：陈奕昆 2011-4-25
//
// 修改标识：
// 修改描述：
//
// 修改标识：
// 修改描述：
//----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using KHMI.Attributes;

namespace DrawTools
{
    [Serializable]
    public class DrawArc : DrawRectangle
    {
        private int startArc;
        [ExtendCategoryAttribute("扩展设置", VectorName = "开始弧度")]
        public int StartArc
        {
            get { return startArc; }
            set { startArc = value; }
        }

        private int endArc = 180;
        [ExtendCategoryAttribute("扩展设置", VectorName = "结束弧度")]
        public int EndArc
        {
            get { return endArc; }
            set { endArc = value; }
        }

        public DrawArc()
            : this(0, 0, 1, 1)
        {
        }

        public DrawArc(int x, int y, int width, int height)
            : base()
        {
            Rectangle = new Rectangle(x, y, width, height);
            Initialize();
        }

        /// <summary>
        /// Clone this instance
        /// </summary>
        public override DrawObject Clone(DrawObject drawObject)
        {
            base.Clone(drawObject);
            return this;
        }

        // 重载属性保存方法
        public override void SaveToStream(System.Runtime.Serialization.SerializationInfo info, int orderNumber)
        {
            base.SaveToStream(info, orderNumber);
        }

        // 
        public override void LoadFromStream(System.Runtime.Serialization.SerializationInfo info, int orderNumber)
        {
            base.LoadFromStream(info, orderNumber);
        }

        public override void Draw(Graphics g)
        {
            try
            {
                Pen pen = new Pen(Color, PenWidth);
                g.DrawArc(pen, DrawRectangle.GetNormalizedRectangle(Rectangle), StartArc, EndArc);
                pen.Dispose();
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

        }
    }
}
